﻿using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

public class PlayerAttackCheck : MonoBehaviour
{
    private string currentAttack = "Attack1";
    private Dictionary<string, PlayerAttack> attacks = new Dictionary<string, PlayerAttack>();

    public void Awake()
    {
        for(int i = 0; i < transform.childCount; i++)
        {
            Transform child = transform.GetChild(i);
            attacks.Add(child.name, child.GetComponent<PlayerAttack>());
        }
    }

    public PlayerAttack UseAttack(string attack)
    {
        PlayerAttack atk;
        if (attacks.TryGetValue(attack, out atk))
        {
            return atk;
        }
        else
        {
            return null;
        }
    }

    public string GetCurrentAttack()
    {
        return currentAttack;
    }
}
